import { ref, reactive } from "vue";
import http from "../utils/http";

const user = reactive({
  account: "",
  password: "",
  re_password: "",
  remeber: false,
  mobile: "",
  sms_code: "",
  login_type: 0,
  sms_btn_text: "点击获取验证码", // 短信按钮提示
  is_send: false, // 短信发送的标记
  sms_interval: 60, // 间隔时间
  interval: null, // 定时器的标记
  login(data) {
    // 用户登录
    return http.post("/users/login/", data);
  },
  check_mobile(mobile) {
    // 检查手机号是否已注册
    return http.get(`/users/mobile/${mobile}`);
  },
  register(data) {
    // 用户注册
    return http.post("/users/register/", data);
  },
  get_sms_code() {
    // 获取短信验证码
    return http.get(`/users/sms/${this.mobile}`);
  },
});

export default user;
